<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('订单批次查询')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse" >
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>客户名称：</label>
                            <select name="customerName" th:with="si=${cuslist}">
                                <option value="">所有</option>
                                <option th:each="cus : ${si}" th:text="${cus.customerName}" th:value="${cus.customerName}"></option>
                            </select>
                        </li>
                        <li>
                            <label>订单号：</label>
                            <input type="text" name="customerOrder" id="customerOrder"/>
                        </li>
                        <li>
                            生产工单号：
                            <input type="text" name="moId" id="moId"/>
                        </li>
                        <li>
                            <label>批次号：</label>
                            <input type="text" name="lotId" id="lotId"/>
                        </li>
                        <li class="select-time">
                            <label style="width: 100px;">计算日期区间：</label>
                            <input type="text" class="time-input" placeholder="开始日期" name="timeflagStartDate" style="width: 100px;"/>
                            <span>~</span>
                            <input type="text" class="time-input" placeholder="结束日期" name="timeflagEndDate" style="width: 100px;"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="promanage:cusordertrailot:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('promanage:cusordertrailot:edit')}]];
    var removeFlag = [[${@permission.hasPermi('promanage:cusordertrailot:remove')}]];
    var prefix = ctx + "promanage/cusordertrailot";
    var tableinit = true;
    var columns = [
        {
            field: 'NO',
            title: "序号",
            formatter: function (value, row, index) {
                return $.table.serialNumber(index);
            }
        },
        {
            field: 'id',
            title: '编号',
            visible: false
        },
        {
            field: 'timeFlag',
            align: 'center',
            title: '日期时间标识',
            visible: false
        },
        {
            field: 'orderTime',
            align: 'center',
            title: '订单日期',
            sortable: true
        },
        {
            field: 'customerOrder',
            align: 'center',
            title: '订单号',
            formatter: function(value, row, index) {
                return '<a class="" onclick="cusOrderClick(\'' + row.customerOrder + '\')">' + row.customerOrder + '</a>';
            }
        },
        {
            field: 'customerName',
            align: 'center',
            title: '客户名称'
        },
        {
            field: 'orderQty',
            align: 'center',
            title: '订单产品片数',
            sortable: true,
            visible: false
        },
        {
            field: 'moId',
            align: 'center',
            title: '生产工单号',
            sortable: true
        },
        {
            field: 'lotId',
            align: 'center',
            title: '批次号',
            formatter: function(value, row, index) {
                return '<a class="" onclick="lotIdClick(\'' + row.lotId + '\')">' + row.lotId + '</a>';
            },
            sortable: true
        },
        {
            field: 'partType',
            align: 'center',
            title: '产品类型',
            sortable: true
        },
        {
            field: 'partName',
            align: 'center',
            title: '产品名称',
            sortable: true
        },
        {
            field: 'lotType',
            align: 'center',
            title: '批次类型',
            sortable: true
        },
        {
            field: 'priority',
            align: 'center',
            title: '等级',
            visible: false
        },
        {
            field: 'mainQty',
            align: 'center',
            title: '片数',
            sortable: true
        },
        {
            field: 'lotStartTime',
            align: 'center',
            title: '投片时间',
            sortable: true
        },
        {
            field: 'planEndDate',
            align: 'center',
            title: '计划完工日期',
            sortable: true
        },
        {
            field: 'comClass',
            align: 'center',
            title: '当前状态大类',
            sortable: true,
            visible: false
        },
        {
            field: 'state',
            align: 'center',
            title: '状态小类',
            sortable: true
        },
        {
            field: 'countGkb',
            align: 'center',
            title: '总光刻数',
            sortable: true
        },
        {
            field: 'leftGkb',
            align: 'center',
            title: '剩余光刻数',
            sortable: true
        },
        {
            field: 'normTimeDiff',
            align: 'center',
            title: '标准时间差(天)',
            sortable: true,
            formatter: function(value, row, index) {
                if (null == value) {
                    return;
                }
                if (value < 0) {
                    return '<div class="font-bold text-navy">' + value + '</div>';
                } else {
                    return '<div class="font-bold text-danger">' + value + '</div>';
                }
                // return '<a class="" onclick="sumNumClick(\'' + row.partId + '\')">' + row.partId + '</a>';
            }
        },
        {
            field: 'lotShipTime',
            align: 'center',
            title: '入库时间',
            sortable: true,
            visible: false
        },
        {
            field: 'lotCycleTime',
            align: 'center',
            title: '生产周期(天)',
            sortable: true,
            visible: false
        },
        {
            field: 'scrapQty',
            align: 'center',
            title: '报废数量',
            sortable: true,
            formatter: function(value, row, index) {
                return '<a class="" onclick="scrapQtyClick(\'' + row.lotId + '\')">' + row.scrapQty + '</a>';
            }
        }
    ];
    var options = {
        url: prefix + "/qrylist",
        createUrl: prefix + "/add",
        updateUrl: prefix + "/edit/{id}",
        removeUrl: prefix + "/remove",
        exportUrl: prefix + "/qryexport",
        modalName: "订单批次查询",
        columns: columns,
        sortName: "orderTime",
        sortOrder: "desc",
        striped: true
    };

    $(function() {
        if (tableinit) {
            $.table.init(options);
            tableinit = false;
        } else {
            $.table.search();
        }
    });

    // 客户订单超链接
    function cusOrderClick(customerOrder) {
        var url = "promanage/cusorderdetail" + "/orderdetail?customerOrder=" + customerOrder;
        var options = {
            title: '订单详情',
            btn: 0,
            url: url,
            full: true,
            width: 800,
            height: $(window).height() - 50
        };
        $.modal.openOptions(options);
    }

    // 报废片数超链接
    function scrapQtyClick(lotId) {
        var url = "promanage/scrapinfo" + "/link?lotId=" + lotId;
        var options = {
            title: '报废详情',
            btn: 0,
            url: url,
            full: true,
            width: 800,
            height: $(window).height() - 50
        };
        $.modal.openOptions(options);
    }

    // 批次号超链接
    function lotIdClick(lotId) {
        var url = "promanage/cusorderlotwip" + "/wipdetail?lotId=" + lotId;
        var options = {
            title: '批次详情',
            btn: 0,
            url: url,
            full: true,
            width: 800,
            height: $(window).height() - 50
        };
        $.modal.openOptions(options);
    }
</script>
</body>
</html>